/**
 * 根据 页面类型 数据类型 生成对应的 表单控制对象
 * @param {页面类型} pageType
 * @param {数据类型} paramsType
 * @returns {表单控制对象} setPageOption
 * */

const SetPageOption = (pageType, paramsType) => {
  // 数据是否可写
  let readOnly = false;
  // 计算指标是否修改
  let computedWrite = true;
  // 弹窗标题
  let title = '';
  // 指标编码是否修改
  let codeWrite = true;
  // 公式是否为必填项目
  let expRequire = false;
  switch (pageType) {
    case 1:
      title = '新增指标';
      readOnly = false;
      // 新增指标页面 不存在 paramsType
      if (paramsType && paramsType != '3') {
        computedWrite = true;
        expRequire = false;
      } else {
        computedWrite = false;
        expRequire = true;
      }
      codeWrite = true;
      break;
    case 2:
      title = '修改指标';
      readOnly = false;
      if (paramsType != '3') {
        computedWrite = true;
        expRequire = false;
      } else {
        computedWrite = false;
        expRequire = true;
      }
      codeWrite = false;
      break;
    case 3:
      title = '查看指标';
      readOnly = true;
      computedWrite = true;
      codeWrite = false;
      expRequire = false;
      break;
    default:
      title = '';
      readOnly = false;
      computedWrite = true;
      codeWrite = false;
      expRequire = true;
      break;
  }
  return {
    title,
    readOnly,
    computedWrite,
    codeWrite,
    expRequire,
  };
};

export { SetPageOption };
